package com.fcl.mylibrary.ui.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by fang on 2016/9/5.
 */
public class MainTabAdapter extends FragmentPagerAdapter {

    private Context context;
    private List<Fragment> fragments;
    private List<String> titles;

    public MainTabAdapter(FragmentManager manager, Context context, List<Fragment> fragments) {
        super(manager);
        this.context = context;
        this.fragments = fragments;
    }

    public MainTabAdapter(FragmentManager manager, Context context, List<Fragment> fragments, List<String> titles) {
        super(manager);
        this.context = context;
        this.fragments = fragments;
        this.titles = titles;
    }

    public void setTitles(List<String> titles) {
        this.titles = titles;
        notifyDataSetChanged();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}
